﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using System.ServiceModel.Activation;

namespace HandLab.WebApp.AjaxWCF
{
    // 注意: 使用“重构”菜单上的“重命名”命令，可以同时更改代码、svc 和配置文件中的类名“WcfJqueryService”。
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class WcfJqueryService : IWcfJqueryService
    {

        public string GetData ( int value )
        {
            return string.Format("You entered: {0}", value);
        }


        public string[] GetUser ( string Id )
        {
            return new User().GetUser(Convert.ToInt32(Id));
        }
    }

    public class User
    {

        Dictionary<int, string> users = null;
        public User ( )
        {
            users = new Dictionary<int, string>();
            users.Add(1, "pranay");
            users.Add(2, "Krunal");
            users.Add(3, "Aditya");
            users.Add(4, "Samir");
        }

        public string[] GetUser ( int Id )
        {
            var user = from u in users
                       where u.Key == Id
                       select u.Value;

            return user.ToArray<string>();
        }

    }
}
